<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>pset</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="product.html" title="product" />
    <link rel="next" href="ptable.html" title="ptable" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">pset</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="product.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="ptable.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="pset"></a>
      <div class="titlepage"></div>
      <a id="IndexPset" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">pset</span>
        </h2>
        <p>pset — 
      Defines and initializes numeric arrays at orchestra load time.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp136303376"></a>
        <h2>Description</h2>
        <p>
      Defines and initializes numeric arrays at orchestra load time.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp136304624"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>pset</strong></span> icon1 [, icon2] [...]</pre>
      </div>
      <div class="refsect1">
        <a id="idp136306608"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>icon1, icon2, ...</em></span> -- preset values for a MIDI instrument
    </p>
        <p>
      <span class="emphasis"><em>pset</em></span> (optional) defines and initializes numeric arrays at orchestra load time. It may be used as an orchestra header statement (i.e. instrument 0) or within an instrument. When defined within an instrument, it is not part of its i-time or performance operation, and only one statement is allowed per instrument. These values are available as i-time defaults. When an instrument is triggered from MIDI it only gets p1 and p2 from the event, and p3, p4, etc. will receive the actual preset values.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp136309584"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the pset opcode. It uses the file <a class="ulink" href="examples/pset.csd" target="_top"><em class="citetitle">pset.csd</em></a>
      </p>
        <div class="example">
          <a id="idp136311328"></a>
          <p class="title">
            <strong>Example 657. Example of the pset opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
 
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac   <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o pset.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>
 

<span class="ohdr">sr</span> <span class="op">=</span> 44100 
<span class="ohdr">ksmps</span> <span class="op">=</span> 32 
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1 
<span class="ohdr">nchnls</span> <span class="op">=</span> 2 

<span class="oblock">instr</span> 1 <span class="comment">;this shows an example with non-midi use</span>

<span class="opc">pset</span> 1, 0, 1, 220, 0.5 
asig <span class="opc">poscil</span> p5, p4, 1 
     <span class="opc">outs</span> asig, asig
 
<span class="oblock">endin</span> 
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
 
<span class="stamnt">f</span> 1 0 1024 10 1	<span class="comment">;sine wave</span>

<span class="stamnt">i</span> 1 0 1 
<span class="stamnt">i</span> 1 1 1 440 
<span class="stamnt">i</span> 1 2 1 440 0.1 
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
     </p>
        <p> Here is another example of the pset opcode, using pset with midi. It uses the file <a class="ulink" href="examples/pset-midi.csd" target="_top"><em class="citetitle">pset-midi.csd</em></a></p>
        <p>
      </p>
        <div class="example">
          <a id="idp136316464"></a>
          <p class="title">
            <strong>Example 658. Second example of the pset opcode.</strong>
          </p>
          <div class="example-contents">
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
 
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac -+rtmidi=virtual -M0 --midi-key-oct=4 --midi-velocity=5   <span class="comment">;;;realtime audio out and virtual midi keyboard</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o pset-midi.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>
 

<span class="ohdr">sr</span> <span class="op">=</span> 44100 
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1 
<span class="ohdr">nchnls</span> <span class="op">=</span> 2 

<span class="oblock">instr</span> 1

            <span class="opc">pset</span> 0, 0, 3600, 0, 0, 0
iinstrument <span class="op">=</span> p1
istarttime  <span class="op">=</span> p2
iattack     <span class="op">=</span> 0.005
isustain    <span class="op">=</span> p3
irelease    <span class="op">=</span> 0.06
p3          <span class="op">=</span> isustain <span class="op">+</span> iattack <span class="op">+</span> irelease
kdamping    <span class="opc">linsegr</span> 0.0, iattack, 1.0, isustain, 1.0, irelease, 0.0

ioctave     <span class="op">=</span> p4
ifrequency  <span class="op">=</span> <span class="opc">cpsoct</span>(ioctave)
iamplitude  <span class="op">=</span> p5<span class="op">*</span>.15			<span class="comment">;lower volume</span>

<span class="opc">print</span> p1, p2, p3, p4, p5
asig <span class="opc">STKBandedWG</span> ifrequency, iamplitude
     <span class="opc">outs</span> asig, asig

<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">f</span> 0 60	<span class="comment">; runs 69 seconds</span>
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp136318384"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="strset.html" title="strset"><em class="citetitle">strset</em></a>
    </p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="product.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="ptable.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">product </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> ptable</td>
        </tr>
      </table>
    </div>
  </body>
</html>
